package com.wx.fruits.interceptor;

import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.wx.service.impl.WxUserServiceImpl;

import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.common.session.WxSessionManager;
import me.chanjar.weixin.mp.api.WxMpMessageInterceptor;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.bean.WxMpXmlMessage;

public class SubscribeInterceptor implements WxMpMessageInterceptor {
	static Logger logger = LoggerFactory.getLogger(SubscribeInterceptor.class);

	@Override
	public boolean intercept(WxMpXmlMessage wxMessage, Map<String, Object> context, WxMpService wxMpService,
			WxSessionManager sessionManager) throws WxErrorException {
		new WxUserServiceImpl().subscribe(wxMpService, wxMessage.getFromUserName());
		return true;
	}

}
